#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
int dx[5]={0,1,-1,0,1},dy[5]={0,0,1,1,-1};
int map[5500][5500];
int main ()
{
	int n;
	cin>>n;
	memset (map,-1,sizeof (map));
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			map[i][j]=0;
	map[1][1]=1;
	int x=1,y=1,t=1;
	for (int k=2;k<=n*n;k++)
	{
		while (map[x+dx[t]][y+dy[t]]!=0)
		{
			t++;
			if (t>4)
				t=1;
		}
		x+=dx[t];
		y+=dy[t];
		map[x][y]=k;
		if (t==1||t==3)
			t++;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
			cout<<setw (3)<<map[i][j];
		cout<<endl;
	}
	return 0;
}
